package com.example.whatrubbish.service.impl;

import com.example.whatrubbish.mapper.RubbishMapper;
import com.example.whatrubbish.model.Rubbish;
import com.example.whatrubbish.service.RubbishService;
import com.example.whatrubbish.vo.Criteria;
import com.example.whatrubbish.vo.RubbishWithSort;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class RubbishServiceImpl implements RubbishService {
    @Autowired
    RubbishMapper rubbishMapper;

    @Override
    public List<RubbishWithSort> selectByName(RubbishWithSort record) {
        record.setName("%" + record.getName() + "%");
        return rubbishMapper.selectByName(record);
    }

    @Override
    public Long selectCountBySortId(Criteria criteria) {
        return rubbishMapper.selectCountBySortId(criteria);
    }

    @Override
    public List<RubbishWithSort> selectBySortId(Criteria criteria) {
        return rubbishMapper.selectBySortId(criteria);
    }

    @Override
    public List<Rubbish> selectRecommend() {
        return rubbishMapper.selectRecommend();
    }

    @Override
    public List<Map<String, Object>> selectRubbishDistribute() {
        return rubbishMapper.selectRubbishDistribute();
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return rubbishMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int recoverByPrimaryKey(Long id) {
        return rubbishMapper.recoverByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKey(Rubbish record) {
        return rubbishMapper.updateByPrimaryKey(record);
    }

    @Override
    public int deleteByList(List<RubbishWithSort> list) {
        return rubbishMapper.deleteByList(list);
    }

    @Override
    public int insertSelective(Rubbish record) {
        return rubbishMapper.insertSelective(record);
    }
}
